<template>
    <div>
        <h1>管理员登录</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">管理员名称</td>
                    <td>
                        <input type="text" v-model="query.name"/>
                    </td>
                </tr>
                <tr>
                    <td align="right">管理员密码</td>
                    <td>
                        <input type="password" v-model="query.pass"/>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" class="btn btn-primary" @click="ok"/>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,reactive,onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
const router=useRouter();
const route=useRoute();

let query:any=reactive
({
    name:'',
    pass:''
})

const ok=()=>
{
    if(query.name=="")
    {
        alert("管理员名称不能为空");
        return;
    }
    if(query.pass=="")
    {
        alert("密码不能为空");
        return;
    }
    axios
    ({
        url:'/api/House/LoGin',
        method:'get',
        params:query
    })
    .then(res=>{
        if(res.data==-1)
        {
            alert("账号错误");
            return;
        }
        if(res.data==-2)
        {
            alert("密码错误");
            return;
        }
        alert("登录成功");
        router.push("/numberAdd");
        return;
    })
    .catch(err=>{
        
    })
}


</script>

<style scoped>

</style>